<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <link rel="shortcut icon" href="../../src/images/bitbug_favicon.ico" type="image/x-icon">
  <meta name="keywords" content="your keywords">
  <meta name="description" content="your description">
  <meta name="author" content="author,email address">
  <meta name="robots" content="index,follow">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="renderer" content="ie-stand">
  <title>仁和区党群服务一号通暨群众意见受理中心</title>
  <link rel="stylesheet" href="../../src/css/base.css">
  <link rel="stylesheet" href="../../src/css/common.css">
  <link rel="stylesheet" href="../../src/css/tpl.css">
  <link rel="stylesheet" href="../../src/css/user_center.css">

  <body>
    <div class="page">
      <div id="header"></div>
      <div class="menu-bar">
        <div class="container">
          <span>
              <span class="crumb-name">当前你的位置：</span>>
          <span>
                   <a href="../Home/Index.html">首页</a>>
            </span>
          <span>投诉处理</span>
        </div>
      </div>

      <div class="container">
      </div>
      <!--正文-->
      <div class="mid_container clearfix">

        <div class="left_guide">
          <h1 class="left_guide_top_size">
            投诉处理
          </h1>
          <div class="left_guide_decorate">
          </div>
          <div class="left_about_us">
            COMPLAIN HANDING
          </div>
          <div class="left_white_about active">
            <a href="Index.html"><span class="left_cn_about_us">投诉处理</span></a>
          </div>
        </div>
        <div class="mid_guide">
          <div class="mid_guide_content">
            <div class="audit_content">
              <div id="info_html"></div>
              <div class="audit_title title_4">跟踪进度</div>
              <div id="feedback_html"></div>
              <div id="comment_html"></div>
            </div>
            <div class="btn_bar" style="display:none">
              <input type="button" value="提交" class="butt red" onclick="Comment()">
              <a href="javascript:;" onclick="history.go(-1)"><input type="button" value="返回" class="butt white"></a>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div id="footer"></div>
    <!-- 详情 -->
    <script type="text/html" id="info_tpl">
      <div class="audit_title title_1">{{title}}</div>
      <div class="audit_info">
        <div class="audit_info_row clearfix">
          <div class="fl left">事发时间：</div>
          <div class="right">{{incidenttime}}</div>
        </div>
        <div class="audit_info_row clearfix">
          <div class="fl left">事发地址：</div>
          <div class="right">{{address}}</div>
        </div>
        <div class="audit_info_row clearfix">
          <div class="fl left">投诉时间：</div>
          <div class="right">{{createtime}}</div>
        </div>
        <div class="audit_info_row clearfix">
          <div class="fl left">投诉编号：</div>
          <div class="right">{{id}}</div>
        </div>
        <div class="audit_info_row clearfix">
          <div class="fl left">投诉内容：</div>
          <div class="right unlimited"> {{content}}</div>
        </div>
        <div class="audit_info_row last_row clearfix">
          <div class="fl left">相关图片：</div>
          <div class="right unlimited">
            {{each picurllist val idx}}
            <div class="show" style="background: url({{val.smallpic}}) center;background-size: cover"></div>
            {{/each}}
            {{if picurllist === null}}未上传图片{{/if}}
          </div>
        </div>
      </div>
    </script>

    <!-- 待处理-->
    <script type="text/html" id="feedback1">
      <div class="audit_info">
        <div class="progression first">
          <div class="title">相关单位待受理</div>
          <div class="date">{{createtime}}</div>
        </div>
      </div>
    </script>
    <!-- 受理中  -->
    <script type="text/html" id="feedback3">
      <div class="audit_info">
        {{each resultdata val idx}}
        <div class="progression first">
          <div class="title">{{val.stepname}}</div>
          <div class="content">
            {{val.remark}}
          </div>
          <div class="date clearfix">{{val.time}}{{if val.remark.length > 95}}<span class="unfold fr">展开▼</a> {{/if}}</span></div>
        </div>
        {{/each}}
      </div>
    </script>
    <!-- 待评价-->
    <script type="text/html" id="feedback4">
      <div class="audit_info">
        <div class="audit_info_row clearfix" style="margin-bottom:15px;">
          <div class="fl left">服务打星：</div>
          <div class="right">
            <ul class="rating js_rating clearfix">
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
            </ul>
            <input type="hidden" value="" name="rating" id="selectvalues">
          </div>
        </div>
      </div>
    </script>
    <!-- 已完结 -->
    <script type="text/html" id="feedback5">
      <div class="audit_info">
        <div class="audit_info_row clearfix" style="margin-bottom:15px;">
          <div class="fl left">服务打星：</div>
          <div class="right unlimited">
            <ul class="rating  clearfix">
              <li></li>
              <li></li>
              <li></li>
              <li></li>
              <li></li>
            </ul>
          </div>
        </div>
        <!-- <div class="audit_info_row clearfix" style="margin-bottom:15px;">
        <div class="fl left">评价日期：</div>
        <div class="right">
          {{createtime}}
        </div>
      </div> -->
      </div>
    </script>
    <script src="../../src/js/libs/jquery.1.12.4.js"></script>
    <script src="../../src/js/libs/template-web.js"></script>
    <script src="../../src/js/libs/layer/layer.js"></script>
    <script src="../../src/js/base/common.js"></script>
    <script>
      var params = {
        id: window.location.href.split('?')[1].split('=')[1],
        userid: document.cookie.split(";")[1].split("=")[1]
      }

      var pageindex = 5

      $(document).on('click', '.js_rating li', function () {
        var idx = $(this).index()
        $('#selectvalues').val(idx)
        $('input[name="rating"]').val(idx)
        $('.rating li').each(function (index, el) {
          $(el).removeClass('active')
          if (index <= idx) {
            $(el).addClass('active')
          }
        })
      })

      $(document).on('click', '.unfold ', function () {
        if ($(this).hasClass('active')) {
          $(this).text('展开▼')
          $(this).parents('.progression').find('.content').css('max-height', '45px')
        } else {
          $(this).text('收起▲')
          $(this).parents('.progression').find('.content').css('max-height', 'initial')
        }
        $(this).toggleClass('active')
      })

      $.ajax({
        url: 'http://221.10.2.222:5680/api/ow/Complain/Model/' + params.id,
        type: "GET",
        dataType: "json",
        success: function (res) {
          var info = template('info_tpl', res)
          $('#info_html').html(info)
          if (res.status == '1' || res.status == '2') {
            var feedback = template('feedback1', res)
            $('#feedback_html').html(feedback)
          } else if (res.status == '3') {
            getStep()
          } else if (res.status == '4') {
            var feedback4 = template('feedback4', res)
            getStep(feedback4)
            $('#feedback_html').append(feedback)
            $('.btn_bar').show()
          } else if (res.status == '5') {
            getjudge()
            getStep()
          } else {
            getStep()
          }
        }
      })

      function getStep(feedback) {
        $.ajax({
          url: 'http://221.10.2.222:5680/api/ow/Complain/StepList/' + params.id,
          type: "GET",
          dataType: "json",
          success: function (res) {
            res.resultdata = JSON.parse(res.resultdata)
            var feedback3 = template('feedback3', res)
            $('#feedback_html').append(feedback3)
            if (feedback) {
              $('#feedback_html').append(feedback)
            }
          }
        })
      }

      function getjudge() {
        $.ajax({
          url: 'http://221.10.2.222:5680/api/ow/Complain/Comment/Detail/' + params.id,
          type: "GET",
          dataType: "json",
          success: function (res) {
            var comment = template('feedback5', res)
            $('#comment_html').html(comment)
            var star = parseInt(res.content)
            $('.rating li').each(function (index, el) {
              if (index <= star) {
                $(el).addClass('active')
              }
            })
          }
        })
      }

      function Comment() {
        if ($("#selectvalues").val() == '') {
          return layer.msg("请选择评价打星！")
        }
        var news = {
          "consumersid": params.userid,
          "complainid": parseInt(params.id),
          "content": $("#selectvalues").val(),
          "score": 5
        }
        $.ajax({
          type: "POST",
          url: "http://221.10.2.222:5680/api/ow/Complain/Comment",
          dataType: "json",
          data: news,
          success: function (data) {
            if (data.result > 0) {
              layer.msg("评论成功！", {
                time: 1500
              }, function () {
                window.location.href = "../Complain/Index.html";
              })
            } else {
              layer.msg("评论失败！")
            }
          }
        });

      }
    </script>
  </body>

</html>